package com.web_bloks.jsonp.client;

/**
 * 
 * @author Jean-Lou Dupont
 *
 */
public class JSONPCallbackResponse {

	public enum Code {
		NA, OK, TIMEOUT
	}
	
	/**
	 * Status Code
	 *  true:  callback performed
	 *  false: callback not performed
	 */
	boolean status = false;
	
	/**
	 * Error code
	 */
	Code errorCode = Code.NA;
	
	/**
	 * Response object
	 */
	Object o = null;
	
	/*===================================================================
	 * CONSTRUCTORS 
	 ===================================================================*/
	/**
	 * Used to create a 'call complete' object with a response code
	 */
	public JSONPCallbackResponse(Code code) {
		super( );
		this.status    = true;
		this.errorCode = code;	
	}

	
	public JSONPCallbackResponse(Object obj) {
		super();
		this.o = obj;
	}


	/*===================================================================
	 * PUBLIC INTERFACE
	 * 
	 *  CommandStatus
	 ===================================================================*/
	/**
	 * Returns the status
	 *  true:  callback performed
	 *  false: callback not performed
	 *  
	 * @return boolean
	 */
	public boolean getStatus() {
		return this.status;
	}
	
	public Code getErrorCode() {
		return this.errorCode;
	}
	
	public boolean isError() {
		return ( this.status == true && (this.errorCode != Code.OK ) );
	}
	
	public void setResponseObject(Object o) {
		this.o = o;
	}
	
	public Object getResponseObject() {
		return this.o;
	}
	/*===================================================================
	 * Recycling
	 ===================================================================*/
	public void _clean() {
	}

}//END